|
| Contents | |
| Introduction |
The core Music Object API is comprised of three core components: Basic, Advanced, and Compatibility. These core components are available separately in the form of JavaScript files. Each core component provides a certain subset of the capabilities of the core Music Object API ("music-object.js"), so when using the separate core component JavaScript files, the core components may be used together in different combinations, depending on the needs of the sonification job at hand.
Dividing the core Music Object API into logical core components provides authors with a way to potentially reduce the load time of sonified pages. For instance, if a particular sonified Web site was only targeted to an audience that already had the Beatnik Player installed, or if a gateway page for the site ensured that all those who entered already had the Player installed, then using the compatibility core component in sonified pages of the site would be unnecessary. So, one could then use only the basic and advanced core components. For convenience, core components can also be combined together into a Music Object Suite, as per the specific needs of any given sonification job.
Using the Music Object core components is easy. Components are simply JavaScript files like the "music-object.js" file that can be sourced into sonified pages as needed. In the following example, the basic and compatibility core components are being used...
<HTML><TITLE>Page Using Music Object Core Components</TITLE></HTML>
<BODY>
<SCRIPT SRC="music-object-c-basic.js"></SCRIPT>
<SCRIPT SRC="music-object-c-compatibility.js"></SCRIPT>
<SCRIPT LANGUAGE=JavaScript><!-- //
// ***************************
// SOME SONIFICATION SCRIPTING
// ***************************
// --></SCRIPT>
<!-- ****************** -->
<!-- SOME SONIFIED HTML -->
<!-- ****************** -->
</BODY></HTML>
|
In another example, if none of the features of the compatibility component need to be used because it is expected that all the visitors to a sonified Web page will already have the Beatnik Player installed, and none of the features of the advanced component need to be used because the page sonification is only making use of Music Object's play and stop methods, then only the basic component needs to be sourced in. The HTML for such a page would look as follows...
<HTML><TITLE>Page Using Just the Basic Core Component</TITLE></HTML>
<BODY>
<SCRIPT SRC="music-object-c-basic.js"></SCRIPT>
<SCRIPT LANGUAGE=JavaScript><!-- //
// ***************************
// SOME SONIFICATION SCRIPTING
// ***************************
// --></SCRIPT>
<!-- ****************** -->
<!-- SOME SONIFIED HTML -->
<!-- ****************** -->
</BODY></HTML>
|
When all three core components are sourced into a page as separate JavaScript files, this has the same effect as sourcing in the standard "music-object.js" file.
So, in other words, the following code...
<SCRIPT SRC="music-object-c-basic.js"></SCRIPT> <SCRIPT SRC="music-object-c-advanced.js"></SCRIPT> <SCRIPT SRC="music-object-c-compatibility.js"></SCRIPT> |
...has the same effect as just...
<SCRIPT SRC="music-object.js"></SCRIPT> |
Technically, it's not incorrect to source in all three core components as separate JavaScript files. But, it's usually better to reduce the number of connections that a page makes to the server to retrieve resources, as each connection can incur a slight delay in page loading. In most cases, sourcing in all three core components is inefficient, unless the majority of the sonified pages in a Web site use only some of the core components, and only a few of the pages need to use all three core components. In this case, two of the core components may already have been cached by the time a page is loaded that is using all three components, and then the extra load time will only be for the additional component that is not yet cached, as opposed to loading in the entire "music-object.js" file.
If you are using the core components in sonification of a Web site, then you will need to use your own judgement in deciding if it's more efficient overall for your site to source in all three components for pages that need the full Music Object API, or more efficient to source in the "music-object.js" file in such cases.
| Rules for Sourcing in Core Components |
The following rules can be used to check that you are sourcing in the core components correctly. If the way you are sourcing in the core components complies with all of the following rules, then the core components will be able to function correctly.
The following notes should act as a further guide when using core components...
| Getting the Core Components |
If you have the downloaded version of this documentation, then you can simply grab the core component JavaScript files from the documentation's "javascript" folder. The files are named "music-object-c-basic", "music-object-c-advanced", and "music-object-c-compatibility".
Alternatively, you can use the links provided below. To get one of the core component JavaScript files from the list, simply right-click on its link (click-and-hold for Mac users). Then, from the menu that pops up, select the 'Save Link As...' or 'Save Target As...' option and save the file into an appropriate folder of the local copy of your Web site. Make sure to save the file with the correct filename (as shown in the list).
| Music Object Component - Basic |
The basic core component provides the most basic and limited set of functionality that may be required in very simply sonification, such as the ability to play, pause, and stop music for a Music Object instance, as well as the ability to set an instance's playback volume. The basic component also provides the foundation for the advanced component, and the basic component is always needed when the advanced component is used. On the other hand, the compatibility component, which can stand alone, does not require the basic component.
There are typically only three cases where the basic component will be used...
For a breakdown of the exact methods and properties defined by the basic core component, see the section How Features are Divided Between the Components.
To get the basic component's JavaScript file, see the section Getting the Core Components.
| Music Object Component - Advanced |
The advanced component exposes all of the really powerful features of the Music Object API. If realtime music remixing is your thing, then this is the component for you. The majority of the core Music Object API is implemented in this component.
Because the basic component provides the foundation for the advanced component, it is not possible to use the advanced component without the basic component being sourced in. Not only must the basic component be sourced into pages that use the advanced component, but the basic component must be sourced in before the advanced component.
Consider the following examples. The first example below is incorrect because the advanced component needs the foundation provided by the basic component to build upon. The advanced component cannot stand alone.
| INCORRECT |
<SCRIPT SRC="music-object-c-advanced.js"></SCRIPT> |
The next example, directly below, is also incorrect. The basic component must be sourced in first, because the advanced component needs to build upon the foundation provided by the basic component.
| INCORRECT |
<SCRIPT SRC="music-object-c-advanced.js"></SCRIPT> <SCRIPT SRC="music-object-c-basic.js"></SCRIPT> |
Whereas, the previous two examples were incorrect, the final example below is correct because the basic component is sourced in first, defining the foundation that the advanced component builds upon when it is sourced into the page.
| CORRECT |
<SCRIPT SRC="music-object-c-basic.js"></SCRIPT> <SCRIPT SRC="music-object-c-advanced.js"></SCRIPT> |
For a breakdown of the exact methods and properties defined by the advanced core component, see the section How Features are Divided Between the Components.
To get the advanced component's JavaScript file, see the section Getting the Core Components.
| Music Object Component - Compatibility |
The compatibility component provides all the compatibility features of the core Music Object API. Using the features in this component, you can gain complete control over how your sonified content behaves when users don't have the Beatnik Player already installed.
Unlike the advanced component, the compatibility component can stand alone and does not require that the basic component be sourced in first. This makes it ideal for use on a gateway page of a sonified Web site that is intended to channel visitors who don't have the Beatnik Player installed through the installation process. If the compatibility test is only to be performed once - on the site's gateway page - then all other sonified pages in the site do not need to use the compatibility component.
Although the compatibility component can stand alone, if you do use it with the other core components, then it must be sourced in after the basic component. Consider the following examples. The first example, below, is incorrect because the compatibility component is sourced in first. When the basic component is used, then the basic component must always be the first component sourced into the page.
| INCORRECT |
<SCRIPT SRC="music-object-c-compatibility.js"></SCRIPT> <SCRIPT SRC="music-object-c-basic.js"></SCRIPT> |
The second example, below, is correct because the basic component must never be sourced in after the other core components. In this case, it is correctly sourced in first.
| CORRECT |
<SCRIPT SRC="music-object-c-basic.js"></SCRIPT> <SCRIPT SRC="music-object-c-compatibility.js"></SCRIPT> |
For a breakdown of the exact methods and properties defined by the compatibility core component, see the section How Features are Divided Between the Components.
To get the compatibility component's JavaScript file, see the section Getting the Core Components.
| How Features are Divided Between the Components |
The following table illustrates how the public authoring API features (methods and properties) of the core Music Object API are broken up between the three core components. Each column of the table represents a core component, and each row in the table represents a type of feature of the Music Object API (instance methods, static methods, instance properties, and static properties).
|
| Building Components Into a Suite |
It is possible to build a custom Music Object suite that combines only those core components that are absolutely necessary for your specific circumstances. By excluding a core component that may not be necessary under your circumstances, you can reduce the size of the JavaScript file that needs to be sourced into your sonified pages. For more information, consult the section Making a Custom Music Object Suite